/*
 * @Author: szx
 * @Date: 2022-03-30 14:12:44
 * @LastEditTime: 2022-03-30 14:24:06
 * @Description:
 * @FilePath: \leetcode\剑指offerII\003\003.js
 */
/**
 * @param {number} n
 * @return {number[]}
 */
var countBits = function (n) {
    const dp = new Array(n + 1).fill(0);
    for (let i = 1; i <= n; i++) {
        const j = i >> 1;
        dp[i] = dp[j] + (i & 1);
    }
    return dp;
};
// 0 1 10 11 100 101
console.log(countBits(5));
